/*global _, DPL, Zepto, jQuery, $, $LAB, iScroll */
/*jslint devel: true, browser: true, undef: true, sloppy: true, regexp: true, plusplus: true,
vars: true, nomen: true, white: true, maxlen: 150, indent: 4 */
////////////////////  lab official - fully compatible  ////////////////////
//min <640b
(function(g,b,d){var c=b.head||b.getElementsByTagName("head"),D="readyState",E="onreadystatechange",F="DOMContentLoaded",G="addEventListener",H=setTimeout;
function f(){
   // $LAB stuff here
}
H(function(){if("item"in c){if(!c[0]){H(arguments.callee,25);return}c=c[0]}var a=b.createElement("script"),e=false;a.onload=a[E]=function(){if((a[D]&&a[D]!=="complete"&&a[D]!=="loaded")||e){return false}a.onload=a[E]=null;e=true;f()};

a.src="/path/to/LAB.js";

c.insertBefore(a,c.firstChild)},0);if(b[D]==null&&b[G]){b[D]="loading";b[G](F,d=function(){b.removeEventListener(F,d,false);b[D]="complete"},false)}})(this,document);


//dev
(function (global, oDOC, handler) {
    var head = oDOC.head || oDOC.getElementsByTagName("head");

    function LABjsLoaded() {
        // do cool stuff with $LAB here
    }

    // loading code borrowed directly from LABjs itself
    setTimeout(function () {
        if ("item" in head) { // check if ref is still a live node list
            if (!head[0]) { // append_to node not yet ready
                setTimeout(arguments.callee, 25);
                return;
            }
            head = head[0]; // reassign from live node list ref to pure node ref -- avoids nasty IE bug where changes to DOM invalidate live node lists
        }
        var scriptElem = oDOC.createElement("script"),
            scriptdone = false;
        scriptElem.onload = scriptElem.onreadystatechange = function () {
            if ((scriptElem.readyState && scriptElem.readyState !== "complete" && scriptElem.readyState !== "loaded") || scriptdone) {
                return false;
            }
            scriptElem.onload = scriptElem.onreadystatechange = null;
            scriptdone = true;
            LABjsLoaded();
        };
        scriptElem.src = "/path/to/LAB.js";
        head.insertBefore(scriptElem, head.firstChild);
    }, 0);

    // required: shim for FF <= 3.5 not having document.readyState
    if (oDOC.readyState == null && oDOC.addEventListener) {
        oDOC.readyState = "loading";
        oDOC.addEventListener("DOMContentLoaded", handler = function () {
            oDOC.removeEventListener("DOMContentLoaded", handler, false);
            oDOC.readyState = "complete";
        }, false);
    }
})(window, document);



////////////////////  my mod - fx 3.6+ and other  ////////////////////
//my mod
(function (d) {
	setTimeout(function () {
		var e = d.createElement('script'), b = 0, o = 'onreadystatechange', r = 'readyState';
		e.onload = e[o] = function () {
			if ((e[r] && e[r] !== "complete" && e[r] !== "loaded") || b) {
				return;
			} else {
				e.onload = e[o] = null;
				b = 1;
				ini();
			}
		};
		e.src = src;
		var s = d.getElementsByTagName('script')[0];
		s.parentNode.insertBefore(e, s);
	}, 0);
	var src = '/dpl/js/lab.js';
	function ini() {
		/** $LAB.script('js/lib.js').wait()
			.script('js/underscore.ext.js').wait()
			.script('js/dpl.js'); **/
	}
}(document));

//min <400b
(function(d){setTimeout(function(){var e=d.createElement('script'),b=0,o='onreadystatechange',r='readyState';
e.onload=e[o]=function(){if((e[r]&&e[r]!=="complete"&&e[r]!=="loaded")||b){return}else{e.onload=e[o]=null;b=1;ini()}};
e.src=src;var s=d.getElementsByTagName('script')[0];s.parentNode.insertBefore(e,s)},0);
var src='/dpl/js/lab.js';
function ini(){
	/** $LAB.script('js/lib.js').wait()
		.script('js/underscore.ext.js').wait()
		.script('js/dpl.js') **/
}
}(document));



////////////////////  my mod - no ie  ////////////////////
//my mod
(function (d) {
	setTimeout(function () {
		var e = d.createElement('script');
		e.onload = function () {
			e.onload = null;
			ini();
		};
		e.src = src;
		var s = d.getElementsByTagName('script')[0];
		s.parentNode.insertBefore(e, s);
	}, 0);
	var src = '/dpl/js/lab.js';
	function ini() {
		/** $LAB.script('js/lib.js').wait()
			.script('js/underscore.ext.js').wait()
			.script('js/dpl.js'); **/
	}
}(document));


//min <260b
(function(d){setTimeout(function(){var e=d.createElement('script');e.onload=function(){e.onload=null;ini()};
e.src=src;var s=d.getElementsByTagName('script')[0];s.parentNode.insertBefore(e,s)},0);
var src='/dpl/js/lab.js';
function ini(){
}
}(document));

